var fs = require('fs')
fs.stat('../1.readFile/test.txt', (err, data) => {
  if (err) {
    console.log(err)
    return false
  } else {
    console.log(data)
  }
})


fs.open('../1.readFile/test.txt', 'a', (err, fd) => {
  if (err) {
    console.log(err)
    return false
  } else {
    fs.fstat(fd, (err, data) => {
      if (err) {
        console.log(err)
      } else {
        console.log(data)
      }
    })
  }
})

function getAllFileFromPath(path) {
  fs.readdir(path, (err, res) => {
    console.log('res', res)
    for (let subpath of res) {
      var statObj = fs.statSync(`${path}/${subpath}`)
      if (statObj.isDirectory()) {
        console.log(`Dir: ${subpath}`)
        getAllFileFromPath(subpath)
      } else {
        console.log(`File: ${subpath}`)
      }
    }
  })
}
getAllFileFromPath(__dirname)